package heven.holt.library.model

import androidx.room.Entity
import androidx.room.Index
import androidx.room.PrimaryKey

@Entity(indices = [Index(value = ["url"], unique = true)])
data class DownloadInfo(
    @PrimaryKey(autoGenerate = true) val id: Int?,
    val url: String,
    val path: String?,
    var totalLength: Long,
    var length: Long
) {
    constructor(url: String) : this(null, url, null, 0, 0)

    val fileName: String
        get() = url.substringAfterLast("/")

    val completeDownload: Boolean
        get() = totalLength != 0L && totalLength == length
}
